package uy.edu.um.ltic.client.gui;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;

public class Reportes extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	private static Reportes instance;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Reportes frame = new Reportes();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */

	public static Reportes getInstance() {
		if (instance == null) {
			instance = new Reportes();
		}
		return instance;
	}

	private Reportes() {
		this.setResizable(false);
		setTitle("Reportes");
		//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);

		JButton btnCantpalEsc = new JButton("Cantidad de palabras escritas");
		btnCantpalEsc.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				ReporteCantidadPalabras window = new ReporteCantidadPalabras();
				window.setVisible(true);
				Reportes.getInstance().setVisible(false);
			}
		});

		JButton btnBuscarPorPalabra = new JButton("Buscar por palabra");
		btnBuscarPorPalabra.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				ReporteBuscarPorPalabra window = new ReporteBuscarPorPalabra();
				window.setVisible(true);
				Reportes.getInstance().setVisible(false);
			}
		});

		JButton btnAtras = new JButton("Atr\u00E1s");
		btnAtras.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				AltasBajasModificacion.getInstance().setVisible(true);
				dispose();
			}
		});
		GroupLayout gl_contentPane = new GroupLayout(contentPane);
		gl_contentPane
				.setHorizontalGroup(gl_contentPane
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								gl_contentPane
										.createSequentialGroup()
										.addGap(87)
										.addGroup(
												gl_contentPane
														.createParallelGroup(
																Alignment.TRAILING,
																false)
														.addComponent(
																btnBuscarPorPalabra,
																Alignment.LEADING,
																GroupLayout.PREFERRED_SIZE,
																289,
																GroupLayout.PREFERRED_SIZE)
														.addComponent(
																btnCantpalEsc,
																Alignment.LEADING,
																GroupLayout.PREFERRED_SIZE,
																289,
																GroupLayout.PREFERRED_SIZE))
										.addGap(48))
						.addGroup(
								gl_contentPane.createSequentialGroup()
										.addContainerGap()
										.addComponent(btnAtras)
										.addContainerGap(355, Short.MAX_VALUE)));
		gl_contentPane.setVerticalGroup(gl_contentPane.createParallelGroup(
				Alignment.TRAILING).addGroup(
				gl_contentPane
						.createSequentialGroup()
						.addContainerGap()
						.addComponent(btnAtras)
						.addGap(24)
						.addComponent(btnCantpalEsc,
								GroupLayout.PREFERRED_SIZE, 57,
								GroupLayout.PREFERRED_SIZE)
						.addGap(29)
						.addComponent(btnBuscarPorPalabra,
								GroupLayout.PREFERRED_SIZE, 55,
								GroupLayout.PREFERRED_SIZE)
						.addContainerGap(53, Short.MAX_VALUE)));
		contentPane.setLayout(gl_contentPane);
		
		addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				AltasBajasModificacion.getInstance().setVisible(true);
				dispose();
			}
		});
	}
}
